#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int main()
{
  int x, yA, yB, c, d, randomPlayer, randomHandCount, randomDeckCount;
  struct gameState newGameA, newGameB;

  printf("Now Testing: village Card\n");

  SelectStream(1);
  PutSeed((long)14);

  for(x = 0; x < 1000; x++){

//Make two identical games A and B.
    for (yA = 0; yA < sizeof(struct gameState); yA++){
      ((char*)&newGameA)[yA] = 0;
    }
    for (yB = 0; yB < sizeof(struct gameState); yB++){
      ((char*)&newGameB)[yB] = 0;
    }
    randomPlayer = Random() * MAX_PLAYERS;
    randomHandCount = Random() * MAX_HAND;
    randomDeckCount =  Random() * MAX_DECK;
    //newGameA.whoseTurn = newGameB.whoseTurn = randomPlayer;
    newGameA.handCount[randomPlayer] = newGameB.handCount[randomPlayer] = randomHandCount;
    newGameA.deckCount[randomPlayer] = newGameB.deckCount[randomPlayer] = randomDeckCount;
    newGameA.discardCount[randomPlayer] = newGameB.discardCount[randomPlayer] = Random() * MAX_PLAYERS;
    for(c = 0; c < randomHandCount; c++){
      newGameA.hand[randomPlayer][c] = newGameB.hand[randomPlayer][c] = Random() * 27;
    }
    for(d = 0; d < randomDeckCount; d++){
      newGameA.deck[randomPlayer][d] = newGameB.deck[randomPlayer][d] = Random() * 27;
    }
    newGameA.numActions = newGameB.numActions = (int)(Random());

//Play Card: village
    newGameA.hand[randomPlayer][c] = newGameB.hand[randomPlayer][c] = village;
    newGameA.handCount[randomPlayer]++;
    newGameB.handCount[randomPlayer]++;
    cardEffect(village, 0, 0, 0, &newGameA, randomHandCount, NULL);
	
//Compare game A and B. (A should have same cards and +1 discardCount)
    assert(newGameA.handCount[randomPlayer] == newGameB.handCount[randomPlayer]);
    assert(newGameA.discardCount[randomPlayer] == newGameB.discardCount[randomPlayer]);    
  }

  printf("Everything checks out according to this test.");

  return 0;
}
